package com.huafeng.attendance.action;

import com.opensymphony.xwork2.ActionSupport;
import com.huafeng.attendance.bean.Attendance;
import com.huafeng.attendance.service.AttendanceService;

/**
 * Attendance 删除Action
 * @author waysoft
 */
@SuppressWarnings("serial")
public class DeleteAttendanceAction extends ActionSupport {
	private Attendance attendance;
	private AttendanceService service;
	private Boolean saveFlag;
	private String saveMsg;

	/**
	 * 根据主键删除，单主键删除
	 */
	public String delete() throws Exception{
		try {
			this.service.deleteByAttend_id(attendance.getAttend_id());
			saveFlag = true;
			saveMsg = "删除成功！";
		} catch (Exception e) {
			e.printStackTrace();
			saveFlag = false;
			saveMsg = "删除失败！";
		}
		return "list";
	}

	/**
	 * 根据主键删除，多主键删除
	 * @return
	 * @throws Exception
	 */
	public String deleteAll() throws Exception{
		try {
			this.service.deleteByAttend_id(attendance.getAttend_ids());
			saveFlag = true;
			saveMsg = "删除成功！";
		} catch (Exception e) {
			e.printStackTrace();
			saveFlag = false;
			saveMsg = "删除失败！";
		}
		return "list";
	}

	public Attendance getAttendance() {
		return attendance;
	}

	public void setAttendance(Attendance attendance) {
		this.attendance = attendance;
	}

	public AttendanceService getService() {
		return service;
	}

	public void setService(AttendanceService service) {
		this.service = service;
	}	

	public Boolean getSaveFlag() {
		return saveFlag;
	}

	public void setSaveFlag(Boolean saveFlag) {
		this.saveFlag = saveFlag;
	}

	public String getSaveMsg() {
		return saveMsg;
	}

	public void setSaveMsg(String saveMsg) {
		this.saveMsg = saveMsg;
	}
}
